# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.

import std/strutils
import std/osproc
# import std/

var
  a : string = "add"

a = "helloworld" & $(456)

echo "a is ", a

when isMainModule:
  if "lowor" in a:
    echo "yes"
  else:
    echo "no"

let rc = execCmdEx("ls -l")
echo rc.output
echo rc.exitCode
echo "总用量" in rc.output


import std/os

if not "/tmp/hello.txt".fileExists :
  discard execCmdEx(r"""echo "hello" > /tmp/hello.txt""")

if fileExists "/tmp/hello.txt":
  if "hello" in "/tmp/hello.txt".readFile:
    echo "Yes, File write OK"

echo "NIM"
echo "hello".toHex

var intc = 240
echo  int16(intc).toHex # 2-byte hex

#
# hex string to byte array.
#
import std/sequtils

type ByteArray = array[2, byte]

let hexstr = "0xfc,0x00"

let hexSeq = hexstr.split(",").mapIt(it.strip.parseHexInt.uint8)
echo hexSeq

func toByteArray(s: openArray[byte]): ByteArray =
  # Copy first two elements to ByteArray
  for i in 0 ..< result.len:
    result[result.low + i] = s[i]
    
echo hexSeq.toByteArray

